home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / mickup.arc / MICKUP.ASM < prev    next >
Assembly Source File  |  1991-10-12  |  92KB  |  1,893 lines

  1. ; Program Name    : Mickup.asm
  2. ; Author          : bill buckels
  3. ; Date            : October 1990
  4. ; Function        : TSR Display of Mouse Functions
  5.  
  6. ;Grateful Acknowledgement: TSR Outline and set-up by Jeff Prosise 1986
  7. ;initialization and keyboard scanning and screen write routines verbatim
  8. ;but bios scrolling functions appended with direct screen writes
  9.  
  10. kb_data       equ 60h                       ;keyboard data port
  11. kb_ctrl       equ 61h                       ;keyboard control port
  12. eoi           equ 20h                       ;8259 end-of-interrupt value
  13. int_ctrl_port equ 20h                       ;8259 PIC port
  14. m_key         equ 32h                       ;scan code for 'M' key
  15. alt_key       equ 8                         ;shift code for Alt key
  16. cr            equ  0dh                      ;carriage return
  17. lf            equ  0ah                      ;line feed
  18. null          equ  00h                      ;nothing
  19. ;
  20. bios_data     segment at 40h                ;BIOS data area
  21.               org 63h
  22. addr_6845     dw ?                          ;6845 Index Register address
  23. bios_data     ends
  24. ;
  25. code          segment para public 'code'
  26.               assume cs:code
  27.               org 100h
  28. begin:        jmp initialize                ;jump to initialization code
  29. ;
  30. notice             db 'Copyright(C) 1990 by Bill Buckels'
  31. notice2            db 'programmed by Bill Buckels'
  32.  
  33. ibm_signature      db 'IBM'                 ;EGA BIOS signature
  34. adapter            db 2                     ;0 = CGA, 1 = MDA, 2 = EGA
  35. video_segment      dw 0B800h                ;video segment address
  36. video_page         db ?                     ;current video page
  37. border_attr        db 1bh                   ;window border attribute
  38. text_attr          db 1Fh                   ;window text attribute
  39. header_attr        db 1Eh                   ;window header attribute
  40. reverse_attr       db 4Eh                   ;reverse color attr
  41. title_attr         db 4bh                   ;title attribute
  42. window_row         db 0                     ;row of left corner of window
  43. window_column      db 0                     ;column of left corner of window
  44. start_value        db 0                     ;first mouse function
  45. func_index         db 0                     ;mouse function counter
  46. old_index          db 0                     ;old counter
  47. int_status         db 0                     ;status of interrupt routine
  48. cursor_mode        dw ?                     ;cursor scan line definition
  49. old_int_9h         label dword              ;old interrupt vector
  50. old_keyboard_int   dw 2 dup (?)
  51. screen_buffer      dw offset initialize     ;pointer to screen buffer area
  52. ;
  53. enable_values      db 2Ch,28h,2Dh,29h       ;values to enable CGA display
  54.                    db 2Ah,2Eh,1Eh
  55. ;
  56. ;--------------------------------------------------------------------
  57. ;initialization messages
  58. ;--------------------------------------------------------------------
  59. credit$      db ' Mickup(C) Copyright 1990  by Bill Buckels',cr,lf
  60.              db 'Mouse Function Pop-Up Summary is Now Installed',cr,lf
  61.              db 'Hotkey Combination is Alt-M',cr,lf,'$'
  62.  
  63. header_text  db ' Mickup(C)   Copyright 1990 ' ;window header text
  64.  
  65. titleblock   db '────────────────────────────',cr
  66.              db '    Programmer Reference    ',cr
  67.              db '           and              ',cr
  68.              db '   Mouse Function Summary   ',cr
  69.              db '────────────────────────────',cr
  70.              db '   by William J. Buckels    ',null
  71.  
  72. XMOUSE db 'The mouse requires a resident program called a',  cr
  73.        db 'driver to be able to perform its functions. The', cr
  74.        db 'primary access to the driver is software int 33h',cr
  75.        db 'Before accessing the driver a check should be',   cr
  76.        db 'made to see if it is resident. If neither the',   cr
  77.        db 'offset or segment of the mouse vector are 0,it',  cr
  78.        db 'is safe to issue a mouse function call.',         cr
  79.        db                                                    cr
  80.        db 'Calls to the driver are issued by loading only',  cr
  81.        db 'the registers required for the call, then by',    cr
  82.        db 'issuing int 33h. Primary registers are AX, BX,',  cr
  83.        db 'CX, and DX (m1,m2,m3,and m4). Certain functions', cr
  84.        db '(9,12,20,22, and 24) require long pointers to be',cr
  85.        db 'specified in the ES:DX register pair. Function',  cr
  86.        db '31 returns a long pointer in ES:BX.',             cr
  87.        db                                                    cr
  88.        db 'The driver deals in Mouse screen coordinates',    cr
  89.        db 'which are comensurate with actual video mode.',   cr
  90.        db '───────────────────────────────────────────────', cr
  91.        db '        Use The Cursor Pad To SELECT',            cr
  92.        db '          The Function of Interest',              cr
  93.        db '     Press ENTER to toggle A Summary of Use',     null
  94.  
  95. ;----------------------------------------------------------------
  96. ;mouse function text
  97. ;----------------------------------------------------------------
  98.  
  99. FUNC00  db      ' 0 Initialize Driver        ',  null
  100. FUNC01  db      ' 1 Show Cursor              ',  null
  101. FUNC02  db      ' 2 Hide Cursor              ',  null
  102. FUNC03  db      ' 3 Get Cursor and Button    ',  null
  103. FUNC04  db      ' 4 Set Cursor Position      ',  null
  104. FUNC05  db      ' 5 Get Button Press Data    ',  null
  105. FUNC06  db      ' 6 Get Button Release Data  ',  null
  106. FUNC07  db      ' 7 Set Horizontal Clipping  ',  null
  107. FUNC08  db      ' 8 Set Vertical Clipping    ',  null
  108. FUNC09  db      ' 9 Define Graphics Cursor   ',  null
  109. FUNC10  db      '10 Define Text Cursor       ',  null
  110. FUNC11  db      '11 Read Motion Counters     ',  null
  111. FUNC12  db      '12 Define User Subroutine   ',  null
  112. FUNC13  db      '13 Light Pen Emulation ON   ',  null
  113. FUNC14  db      '14 Light Pen Emulation OFF  ',  null
  114. FUNC15  db      '15 Set Counts per 8-Pixe1s  ',  null
  115. FUNC16  db      '16 Define Cond. OFF Window  ',  null
  116. FUNC17  db      '17 Not available:internal   ',  null
  117. FUNC18  db      '18 Not available:internal   ',  null
  118. FUNC19  db      '19 Set Dble-Speed Threshold ',  null
  119. FUNC20  db      '20 Exchange User Sub Vector ',  null
  120. FUNC21  db      '21 Get Size Mouse State Buff',  null
  121. FUNC22  db      '22 Save Mouse State         ',  null
  122. FUNC23  db      '23 Restore Mouse State      ',  null
  123. FUNC24  db      '24 Define Alternate User Sub',  null
  124. FUNC25  db      '25 Read Alternate Sub Vector',  null
  125. FUNC26  db      '26 Set Scaling Factors      ',  null
  126. FUNC27  db      '27 Get Mouse Scaling Factors',  null
  127. FUNC28  db      '28 Reserved                 ',  null
  128. FUNC29  db      '29 Set Active Display Page  ',  null
  129. FUNC30  db      '30 Get Active Display Page  ',  null
  130. FUNC31  db      '31 Disable Mouse Driver     ',  null
  131. FUNC32  db      '32 Enable Mouse Driver      ',  null
  132. FUNC33  db      '33 Software Reset           ',  null
  133. FUNC34  db      '34 Set Language Byte        ',  null
  134. FUNC35  db      '35 Read Language Byte       ',  null
  135. FUNC36  db      '36 Get Mouse & Driver Data  ',  null
  136.  
  137. ;----------------------------------------------------------------
  138. ;maximum size of explanation is 22 rows x 48 columns
  139. ;each line is seperated by a carriage return and the
  140. ;explanation is terminated with a null byte
  141. ;multiple pages are delineated with a lf as a pagebreak
  142. ;----------------------------------------------------------------
  143.  
  144. XFUNC00  db '       Function 0      Reset Driver',             cr
  145.          db '       ----------------------------',             cr
  146.          db 'Call:   AX  = 0',                                 cr
  147.          db                                                    cr
  148.          db 'Return: AX  = Oxffff if Mouse Driver is Active',  cr
  149.          db '        BX  = Number of Independent Buttons (2)', cr
  150.          db                                                    cr
  151.          db 'This function configures the mouse port and sets',cr
  152.          db 'internal driver variables to Driver Defaults:',   cr
  153.          db                                                    cr
  154.          db 'Cursor Level Counter                        -1',  cr
  155.          db 'Graphics Cursor             Left Leaning UpArrow',cr
  156.          db 'Graphics Cursor Hot Spot                (-1,-1)', cr
  157.          db 'Text Cursor = Rev Video Box:Screen Mask    ffffH',cr
  158.          db '                            Cursor Mask    7700H',cr
  159.          db 'User Subroutine Condition Mask Disabled      0',  cr
  160.          db 'Light Pen Emulation                          ON', cr
  161.          db 'Mouse-Counts per 8-Pixe1s                    8',  cr
  162.          db 'Mouse-Counts per 8-rasters                   16', cr
  163.          db 'Double-Speed Threshold in Mickeys per second 120',cr
  164.          db 'Cursor Range in Pixels                  0 to 639',cr
  165.          db 'Cursor Range in Rasters                 0 to 199',null
  166.  
  167. XFUNC01  db '        Function 1      Show Cursor',             cr
  168.          db '        ---------------------------',             cr
  169.          db 'Call:   AX  = 1',                                 cr
  170.          db                                                    cr
  171.          db 'Return: None',                                    cr
  172.          db                                                    cr
  173.          db 'This function increments the cursor level count', cr
  174.          db 'in the driver. When the cursor level = zero the', cr
  175.          db 'driver will plot the tracking cursor on screen.', cr
  176.          db 'Successive calls to Func 1 will not increase',    cr
  177.          db 'the cursor level above zero.',                    cr
  178.          db                                                    cr
  179.          db 'The cursor level variable is provided as a way',  cr
  180.          db 'for a program to handle multiple levels of',      cr
  181.          db 'hiding a cursor. The mouse cursor is drawn by',   cr
  182.          db 'the driver whenever the user moves his mouse.',   cr
  183.          db 'It is necessary to hide the cursor before',       cr
  184.          db 'altering the screen under the cursor, or',        cr
  185.          db 'scrolling the screen  The cursor level counter',  cr
  186.          db 'keeps hides and shows nested correctly in',       cr
  187.          db 'complex programs.',                               null
  188.  
  189. XFUNC02  db '        Function 2      Hide Cursor',             cr
  190.          db '        ---------------------------',             cr
  191.          db 'Call:   AX  = 2',                                 cr
  192.          db                                                    cr
  193.          db 'Return: None',                                    cr
  194.          db                                                    cr
  195.          db 'This function decrements the cursor level count', cr
  196.          db 'in the driver. If the cursor is currently',       cr
  197.          db 'displayed it will be removed from the screen.',   cr
  198.          db 'Successive calls to Function 2 will continue',    cr
  199.          db 'to decrease the cursor level below zero.Thus you',cr
  200.          db 'must have a matching show for each hide.',        null
  201.  
  202. XFUNC03  db 'Function 3 Get Cursor Position and Button Status',cr
  203.          db '------------------------------------------------',cr
  204.          db 'Call:   AX  = 3',                                 cr
  205.          db                                                    cr
  206.          db 'Return: BX  = Button Status',                     cr
  207.          db 'CX = Horizontal Position in Mouse-Screen Pixels',cr
  208.          db 'DX = Vertical Position in Mouse-Screen Rasters', cr
  209.          db                                                    cr
  210.          db 'Button Status is given in the 2 leastsignificant',cr
  211.          db 'bits of the 16-bit register BX as follows:',      cr
  212.          db '                Bit # ---> 15 14 ... 2  1  0',    cr
  213.          db '                Value --->  0  0 ... 0  R  L',    cr
  214.          db 'where R is Right button and L the Left button.',  cr
  215.          db 'A button bit is one if that button is pressed.',  cr
  216.          db 'Note that pressing the Middle button of the',     cr
  217.          db 'mouse is equivalent to the simultaneous press of',cr
  218.          db 'the Left and Right buttons.The coordinate return',cr
  219.          db 'in CX and DX is in Mouse-Screen coordinates.',  cr
  220.          db 'The mouse driver automatically changes internal', cr
  221.          db 'operating mode and coordinate system on display', cr
  222.          db 'mode change through a BIOS INT10H call.',         null
  223.  
  224. XFUNC04  db '        Function 4      Set Cursor Position',     cr
  225.          db '        ------------------------------------',    cr
  226.          db 'Call  :AX  = 4',                                  cr
  227.          db '       BX  = Mouse-Screen Pixels (Horiz.)',       cr
  228.          db '       CX  = Mouse-Screen Rasters (Vertical)',    cr
  229.          db                                                    cr
  230.          db 'Return:None',                                     cr
  231.          db                                                    cr
  232.          db 'This function sets the XMOUSE cursor to a new',   cr
  233.          db 'position. The coordinates should be within the',  cr
  234.          db 'legal range of coordinates for the type of',      cr
  235.          db 'display screen in use.',                          null
  236.  
  237.  
  238. XFUNC05  db '        Function 5      Get Button Press Data',   cr
  239.          db '        -------------------------------------',   cr
  240.          db 'Call  :AX  = 5',                                  cr
  241.          db '       BX  = Button Number (Left=O, Right=1)',    cr
  242.          db                                                    cr
  243.          db 'Return:AX  = Button Status',                      cr
  244.          db '       BX  = Number of Presses since last call',  cr
  245.          db '       CX  = Mouse-Screen Pixels (H) last Press', cr
  246.          db '       DX  = Mouse-Screen Rasters (V) last Press',cr
  247.          db                                                    cr
  248.          db 'Button Status is given in the 2 leastsignificant',cr
  249.          db 'bits of the 16-bit register BX as follows:',      cr
  250.          db '                Bit # ---) 15 14 ... 2  1  0',    cr
  251.          db '                Value ---)  0  0 ... 0  R  L',    cr
  252.          db 'This function provides a count of the number of', cr
  253.          db 'times a button has been pressed. The count is',   cr
  254.          db 'zeroed after each call to the function. Presses', cr
  255.          db 'are counted separately from releases.The cursor', cr
  256.          db 'coordinates returned in CX and DX are those at',  cr
  257.          db 'the moment of the last button press and may not', cr
  258.          db 'be identical to the current cursor coordinates.', null
  259.  
  260. XFUNC06  db '    Function 6      Get Button Release Data',     cr
  261.          db '    ---------------------------------------',     cr
  262.          db 'Call:  AX  = 6',                                  cr
  263.          db '       BX  = Button Number (Left=O, Right=1)',    cr
  264.          db                                                    cr
  265.          db 'Return:AX  = Button Status',                      cr
  266.          db '       BX  = Number of Releases since last call', cr
  267.          db '       CX  = Mouse-Screen Pixels (H)last Release',cr
  268.          db '       DX  = Mouse-Screen Rasters(V)last Release',cr
  269.          db                                                    cr
  270.          db 'Button Status is given in the 2 leastsignificant',cr
  271.          db 'bits of the 16-bit register BX as follows:',      cr
  272.          db '                Bit # ---) 15 14 ... 2  1  0',    cr
  273.          db '                Value ---)  0  0 --- 0  R  L',    cr
  274.          db 'This function provides a count of the number of', cr
  275.          db 'times a button has been released. The count is',  cr
  276.          db 'zeroed after each call to the function.',         cr
  277.          db 'Releases are counted separately from presses.',   cr
  278.          db 'The cursor coordinates returned in CX and DX',    cr
  279.          db 'are those at themoment of the last release and',  cr
  280.          db 'may not be the current cursor coordinates.',      null
  281.  
  282. XFUNC07  db '       Function 7      Set Horizontal Clipping',  cr
  283.          db '       ---------------------------------------',  cr
  284.          db 'Call:  AX  = 7',                                  cr
  285.          db '       CX  = Minimum Mouse-Screen Pixel',         cr
  286.          db '       DX  = Maximum Mouse-Screen Pixel',         cr
  287.          db                                                    cr
  288.          db 'Return:None',                                     cr
  289.          db                                                    cr
  290.          db 'This function allows you to set the maximum and', cr
  291.          db 'minimum values for the horizontal position of',   cr
  292.          db 'the cursor. The cursor will be moved into the',   cr
  293.          db 'newly defined region if it is not already there.',cr
  294.          db                                                    cr
  295.          db 'If the Maximum Pixel is less than the Minimum',   cr
  296.          db 'then they will be exchanged.',                    null
  297.  
  298. XFUNC08  db '        Function 8      Set Vertical Clipping',   cr
  299.          db '        --------------------------------------',  cr
  300.          db 'Call:  AX  = 8',                                  cr
  301.          db '       CX  = Minimum Mouse-Screen Raster',        cr
  302.          db '       DX  = Maximum Mouse-Screen Raster',        cr
  303.          db                                                    cr
  304.          db 'Return:None',                                     cr
  305.          db                                                    cr
  306.          db 'This function allows you to set the maximum and', cr
  307.          db 'minimum values for the vertical position of the', cr
  308.          db 'cursor. The cursor will be moved into the',       cr
  309.          db 'newly defined region if it is not already there.',cr
  310.          db                                                    cr
  311.          db 'If the Maximum Raster is less than the Minimum',  cr
  312.          db 'then they will be exchanged.',                    null
  313.  
  314.  
  315. XFUNC09  db '  Function 9 (Advanced)   Define Graphics Cursor',cr
  316.          db '  ----------------------------------------------',cr
  317.          db 'Call:  AX  = 9',                                  cr
  318.          db '       BX  = Horizontal Hot Spot',                cr
  319.          db '       CX  = Vertical Hot Spot',                  cr
  320.          db '       DX  = Offset of Far Ptr to 32 int Array',  cr
  321.          db 'Return:None',                                     cr
  322.          db 'The far pointer must  be defined by the ES:DX',   cr
  323.          db 'register Pair. Allows defining new cursor shapes',cr
  324.          db 'for the graphics modes. Two bitmaps, each 16',    cr
  325.          db 'bits square are logically combined with display', cr
  326.          db 'memory to create a cursor; the screen mask map',  cr
  327.          db 'is ANDed with the screen memory and then the',    cr
  328.          db 'result is XORed with the Cursor Mask bitmap.',    cr
  329.          db 'For EGA display modes the same operation is',     cr
  330.          db 'repeated with all of the planes in the display.', cr
  331.          db 'Since the logical operations are conducted',      cr
  332.          db 'directly on screen memory the size of the cursor',cr
  333.          db 'varies with the display mode. e.g in 640 x 200',  cr
  334.          db 'black and white graphics mode the cursor is',     cr
  335.          db '16 pixels by 16 rasters. In the 320 x 200 medres',cr
  336.          db 'color mode the cursor is 8 PELS by 16 rasters.',  null
  337.  
  338. XFUNC10  db '       Function 10     Define Text Cursor',       cr
  339.          db '       ---------------------------------',        cr
  340.          db 'Call :  AX  = 10',                                cr
  341.          db '        BX  = Cursor Type',                       cr
  342.          db '        CX  = Screen Mask (or Scan Line Start)',  cr
  343.          db '        DX  = Cursor Mask (or Scan Line Stop)',   cr
  344.          db                                                    cr
  345.          db 'Return: None',                                    cr
  346.          db                                                    cr
  347.          db 'This function is used to define a cursor in text',cr
  348.          db 'modes.  Cursor Type selects either a software',   cr
  349.          db 'cursor if BX = 0, or a hardware cursor',          cr
  350.          db 'if BX = 1.',                                      null
  351.  
  352. XFUNC11  db '  Function 11 (Advanced)  Read Motion Counters',  cr
  353.          db '  --------------------------------------------',  cr
  354.          db 'Call:  AX  = 11',                                 cr
  355.          db                                                    cr
  356.          db 'Return:CX = Horizontal Mouse-Counts',             cr
  357.          db '       DX = Vertical Mouse-Counts',               cr
  358.          db                                                    cr
  359.          db 'This function provides direct access to relative',cr
  360.          db 'movement of the mouse in mouse motion units or',  cr
  361.          db 'Mouse-Counts(Mickeys).The number of Mouse-Counts',cr
  362.          db 'is proportional to the distance that the mouse',  cr
  363.          db 'moves. Functions #15,19,26 effect the impact of', cr
  364.          db 'mouse motion upon the cursor motion.',            cr
  365.          db                                                    cr
  366.          db 'Positive counts represent horizontal motion to',  cr
  367.          db 'the right and vertical motion down. The counts',  cr
  368.          db 'are signed 16 bit integers, and any overflow is', cr
  369.          db 'ignored. The horizontal and vertical counts are', cr
  370.          db 'zeroed after each call to this function.',        null
  371.  
  372. XFUNC12  db 'Function 12 (Advanced)  Define User Subroutine',  cr
  373.          db '----------------------------------------------',  cr
  374.          db 'Call:  AX  = 12',                                 cr
  375.          db '       CX  = User Defined Event Mask',            cr
  376.          db '       DX  = Offset of Far Ptr to User Sub',      cr
  377.          db 'Return:None',                                     cr
  378.          db 'The far pointer must be defined by the ES:DX',    cr
  379.          db 'register pair. This function defines a set of',   cr
  380.          db 'conditions for which a user defined subroutine',  cr
  381.          db 'will be called by the mouse driver. The user',    cr
  382.          db 'defined subroutine is invoked when a mouse',      cr
  383.          db 'interrupt occurrs and one or more of the',        cr
  384.          db 'conditions defined by the Event Mask are met.',   cr
  385.          db 'The bits of the Event Mask are:',                 cr
  386.          db '   Bit # --->  15 .  .  .  5  4  3  2  1  0',     cr
  387.          db '   Func  ---)   x .  .  .  x Rr Rp Lr Lp  M',     cr
  388.          db 'M  = Mouse Motion has occurred',                  cr
  389.          db 'Lp = Left Button Pressed',                        cr
  390.          db 'Lr = Left Button Released',                       cr
  391.          db 'Rp = Right Button pressed',                       cr
  392.          db 'Rr = Right Button Released',                      cr
  393.          db 'x  = Not used        << press ENTER for MORE >>', lf
  394.  
  395. XFUNC12A db 'Setting an Event Mask bit to one enables the',    cr
  396.          db 'condition.  C1earing all bits to 0 Will disable', cr
  397.          db 'all calls.  Be certain to disable the call to',   cr
  398.          db 'your user defined subroutine Whenever you exit',  cr
  399.          db 'from your application. Otherwise the next mouse', cr
  400.          db 'motion, Whether intentional or not, will cause',  cr
  401.          db 'a call through the now dangling reference to',    cr
  402.          db 'uninitialized memory. When the Event Mask',       cr
  403.          db 'conditions are satisfied and the Mouse Driver',   cr
  404.          db 'calls the User Subroutine, information is',       cr
  405.          db 'available in the following registers:',           cr
  406.          db 'AX = Event Integer - state of Event Mask Bits',   cr
  407.          db 'BX = Button Status',                              cr
  408.          db 'CX = Cursor Pos in Mouse-Screen Pixels',          cr
  409.          db 'DX = Cursor Pos in Mouse-Screen Rasters',         cr
  410.          db 'DI = Motion Counter (Horizontal)',                cr
  411.          db 'SI = Motion Counter (Vertical)',                  cr
  412.          db 'This function should only be used by experienced',cr
  413.          db 'programmers.',                                    null
  414.  
  415. XFUNC13  db '  Function 13     Light Pen Emulation ON',        cr
  416.          db '  --------------------------------------',        cr
  417.          db                                                    cr
  418.          db 'Call   :    AX  = 13',                            cr
  419.          db                                                    cr
  420.          db 'Return :    None',                                cr
  421.          db                                                    cr
  422.          db 'This function turns on emulation of a light pen', cr
  423.          db 'for users of BASIC.',                             cr
  424.          db 'Mouse motion will be used to simulate a light',   cr
  425.          db 'Pen. Pressing a button will store coordinates of',cr
  426.          db 'the cursor. Each call to the BASIC PEN function', cr
  427.          db 'will return a set of coordinates.',               cr
  428.          db                                                    cr
  429.          db 'When no mouse buttons are depressed the PEN func',cr
  430.          db 'will return a pen-up  status.',                   null
  431.  
  432. XFUNC14  db '        Function 14     Light Pen Emulation OFF', cr
  433.          db '        ---------------------------------------', cr
  434.          db 'Call   :    AX  = 14',                            cr
  435.          db                                                    cr
  436.          db 'Return :    None',                                cr
  437.          db                                                    cr
  438.          db 'This function turns off emulation of a light pen',null
  439.  
  440. XFUNC15  db '  Function 15     Set Mouse-Counts per 8-Pixe1s,',cr
  441.          db '                  Mouse-Counts per 8-Rasters',    cr
  442.          db '  --------------------------------------------',  cr
  443.          db                                                    cr
  444.          db 'Call   :AX  = 15',                                cr
  445.          db '        CX  = Mouse-Counts per 8-pixe1s (Hor)',   cr
  446.          db '        DX  = Mouse-Counts per 8-rasters (Vert)', cr
  447.          db                                                    cr
  448.          db 'Return :None',                                    cr
  449.          db                                                    cr
  450.          db 'This function sets the relationship between the', cr
  451.          db 'mouse motion and the cursor motion. Small values',cr
  452.          db 'mean that a small mouse motion produces a large', cr
  453.          db 'cursor motion. Large values mean that a large',   cr
  454.          db 'mouse motion is required to achieve a given',     cr
  455.          db 'cursor motion. The range of these factors should',cr
  456.          db 'be limited to 1 through 32767 but there is no',   cr
  457.          db 'overrange checking. A value exceeding 32767 is',  cr
  458.          db 'interpreted as a negative number and this will',  cr
  459.          db 'reverse cursor motion relative to mouse motion.', null
  460.  
  461. XFUNC16  db 'Function 16 (advanced)  Define Cursor OFF window',cr
  462.          db '------------------------------------------------',cr
  463.          db                                                    cr
  464.          db 'Call Data:    AX = 16',                           cr
  465.          db '              CX = Minimum Mouse-Screen pixel',   cr
  466.          db '              DX = Minimum Mouse-Screen Raster',  cr
  467.          db '              SI = Maximum Mouse-Screen Pixel',   cr
  468.          db '              DI = Maximum Mouse-Screen Raster',  cr
  469.          db 'Return Data:  none',                              cr
  470.          db                                                    cr
  471.          db 'If an application program modifies a region of',  cr
  472.          db 'the screen, the mouse cursor should be OFF so',   cr
  473.          db 'that the screen will not be garbled. To do this,',cr
  474.          db 'the application turns Off the cursor, modifies',  cr
  475.          db 'the screen, then turns ON the cursor.',           cr
  476.          db 'If the cursor is outside of the region being',    cr
  477.          db 'modified, the cursor need not be turned OFF.',    cr
  478.          db 'Unnecessary hiding of the mouse cursor produces', cr
  479.          db 'an annoying cursor blink.',                       cr
  480.          db '                      << press ENTER for MORE >>',lf
  481.  
  482. XFUNC16A db 'This function defines a screen region where the', cr
  483.          db 'cursor wlll not be Plotted. If the mouse cursor', cr
  484.          db 'is within the region when the call is made, or',  cr
  485.          db 'if it enters the region it will be hidden.',      cr
  486.          db                                                    cr
  487.          db 'A call to function 1 is needed to restore the',   cr
  488.          db 'cursor.  Thus the application invokes Function',  cr
  489.          db '#16 followed by a turn-ON of the cursor',         cr
  490.          db '(function # 1). Function #16 will not turn Off',  cr
  491.          db 'the cursor un1ess it is in the defined region so',cr
  492.          db 'blinking is greatly reduced.',                    cr
  493.          db                                                    cr
  494.          db 'In other words, Function #16 allows your',        cr
  495.          db 'software to update a portion of the screen',      cr
  496.          db 'without hiding the cursor before each screen',    cr
  497.          db 'update. Function #l after function #16 does',     cr
  498.          db 'nothing if the cursor Is already ON.',            null
  499.  
  500. XFUNC17  db 'Function 17  Not Available:  Used internally by', cr
  501.          db '                            the Mouse Driver.',   cr
  502.          db '-----------------------------------------------', null
  503.  
  504. XFUNC18  db 'Function 18 Not Available:  Used internally by',  cr
  505.          db '                            the Mouse Driver.',   cr
  506.          db '----------------------------------------------',  null
  507.  
  508. XFUNC19  db 'Function 19     Set Double-Speed Threshold',      cr
  509.          db '------------------------------------------',      cr
  510.          db 'Call:    AX  = 19',                               cr
  511.          db '         DX  = Double-Speed Threshold in',        cr
  512.          db '               Mouse_Counts/second',              cr
  513.          db 'Return : None',                                   cr
  514.          db                                                    cr
  515.          db 'When the mouse is moved faster than this speed',  cr
  516.          db 'threshold the scaling between Mouse-Counts and',  cr
  517.          db 'screen pixels is temporarily doubled to increase',cr
  518.          db 'the response of motion of the mouse cursor. The', cr
  519.          db 'threshold is also affected by the Scaling Factor',cr
  520.          db 'set by Function #26.',                            cr
  521.          db                                                    cr
  522.          db 'The default value is 120 mouse-counts per second',cr
  523.          db 'To effectively disable the doublespeed threshold',cr
  524.          db 'enter a large number that cannot be exceeded ...',cr
  525.          db '15000 for example.',                              null
  526.  
  527. XFUNC20  db 'Func20(Advanced)Exchange User Subroutine Vectors',cr
  528.          db '------------------------------------------------',cr
  529.          db 'Call  :   AX  = 20',                              cr
  530.          db '          CX  = New User Defined Event Mask',     cr
  531.          db '          DX  = New Offset of Far Pointer to',    cr
  532.          db '                     User Defined Subroutine',    cr
  533.          db 'Return:   CX  = Old User Defined Event Mask',     cr
  534.          db '          DX  = Old Offset of Far Pointer to',    cr
  535.          db '                     User Defined Subroutine',    cr
  536.          db 'Far pointers defined by the ES:DX register pair.',cr
  537.          db                                                    cr
  538.          db 'This function is intended to be used by pop-up',  cr
  539.          db 'utilities and other programs that need to',       cr
  540.          db 'temporarily gain control of the mouse driver.',   cr
  541.          db 'By using this function, a popup can save the',    cr
  542.          db 'state of the foreground application Function 12', cr
  543.          db 'subroutine and install its own mouse handler.',   null
  544.  
  545. XFUNC21  db 'Func 21(Advanced) Get Size of Mouse State Buffer',cr
  546.          db '------------------------------------------------',cr
  547.          db                                                    cr
  548.          db 'Call Data:      AX  = 21',                        cr
  549.          db                                                    cr
  550.          db 'Return Data:    BX  = Buffer Size in Bytes',      cr
  551.          db                                                    cr
  552.          db 'This function is intended to be used by popup',   cr
  553.          db 'utilities and other programs that need to',       cr
  554.          db 'temporarily gain control of the mouse driver.',   cr
  555.          db 'By using this function and functions 22 and 23,', cr
  556.          db 'a popup can save the state of the mouse driver',  cr
  557.          db 'as set by the foreground application.',           null
  558.  
  559. XFUNC22  db '   Function 22 (Advanced)  Save Mouse State',     cr
  560.          db '   ----------------------------------------',     cr
  561.          db                                                    cr
  562.          db 'Call  : AX  = 22',                                cr
  563.          db '        DX  = Offset Far Pointer to Save-Buffer', cr
  564.          db                                                    cr
  565.          db 'Return: None',                                    cr
  566.          db                                                    cr
  567.          db 'Far Pointer defined by the ES:DX register pair.', cr
  568.          db                                                    cr
  569.          db 'This function copies the internal state',         cr
  570.          db 'variables to a buffer area so they can be',       cr
  571.          db 'restored by Function 23.',                        null
  572.  
  573. XFUNC23  db '   Function 23 (Advanced) Restore Mouse State',   cr
  574.          db '   ------------------------------------------',   cr
  575.          db 'Call:  AX = 23',                                  cr
  576.          db '       DX = Offset of Far Ptr to Save-Buffer',    cr
  577.          db                                                    cr
  578.          db 'Return:None',                                     cr
  579.          db                                                    cr
  580.          db 'The complete Far Pointer is defined by the',      cr
  581.          db 'ES:DX register pair.',                            cr
  582.          db                                                    cr
  583.          db 'This function restores the internal state',       cr
  584.          db 'variables from the buffer area.',                 null
  585.  
  586. XFUNC24  db 'Func 24 (Advanced) Define Alternate User Sub',    cr
  587.          db '--------------------------------------------',    cr
  588.          db 'Call:  AX = 24',                                  cr
  589.          db '       CX = User Defined Event Mask',             cr
  590.          db '       DX = Offset of Far Ptr to User Sub',       cr
  591.          db 'Return:AX = -1 if error',                         cr
  592.          db 'The complete Far Ptr is defined by ES:DX.',       cr
  593.          db 'Subs for mouse events that occur while Shift,',   cr
  594.          db 'Alt, and/or Ctrl keys are pressed. Subroutine',   cr
  595.          db 'is called when the Event Mask conditions are',    cr
  596.          db 'met. The Event Mask bits are defined:',           cr
  597.          db 'Bit # ->15 .  .  .     7  6  5  4  3  2  1  0',   cr
  598.          db 'FunC  -> X .  .  .  X  A  C  S Rr Rp Lr Lp  M',   cr
  599.          db 'M  = Mouse Motion has occurred',                  cr
  600.          db 'Lp = Left Button Pressed',                        cr
  601.          db 'Lr = Left Button Released',                       cr
  602.          db 'Rp = Right Button Pressed',                       cr
  603.          db 'Rr = Right Button Released',                      cr
  604.          db 'S  = Shift Key',                                  cr
  605.          db 'C  = Ctrl Key',                                   cr
  606.          db 'A  = Alt Key',                                    cr
  607.          db 'x  = Not used         << press ENTER for MORE >>',lf
  608.  
  609. XFUNC24A db 'Setting an Event Mask bit to one enables the',    cr
  610.          db 'condition.  To disable any one of these calls,',  cr
  611.          db ' it is necessary to invoke Function #24 with',    cr
  612.          db 'the specific Comb.of the [A1t,Ctr1,Shift] set',   cr
  613.          db 'and wlth the mouse bits zeroed. Be certain to',   cr
  614.          db 'disable the call to your user defined sub when',  cr
  615.          db 'you exit from your application. Otherwise the',   cr
  616.          db 'next mouse motion will cause a Call through',     cr
  617.          db 'the dangling reference to uninitialized memory.', cr
  618.          db 'These alternate routines will only be called if', cr
  619.          db 'a selected combination of the keys in the set',   cr
  620.          db '[Alt,Ctrl,Shift] is pressed and one or more of',  cr
  621.          db 'the mouse bits are active.  While a table of 7',  cr
  622.          db 'possible subroutines comprises all the possible', cr
  623.          db 'combinations of the three keys the Microsoft',    cr
  624.          db 'driver only supports three alternate routines.',  cr
  625.          db '                       << press ENTER for MORE>>',lf
  626.  
  627. XFUNC24B db 'When the Event Mask conditions are satisfied and',cr
  628.          db 'the Mouse Driver calls the User Subroutine,',     cr
  629.          db 'information concerning the mouse state is',       cr
  630.          db 'available in the following registers:',           cr
  631.          db 'AX = Event Integer - state of Event Mask Bits',   cr
  632.          db 'BX = Button Status',                              cr
  633.          db 'CX = Cursor Position in Mouse-Screen Pixels',     cr
  634.          db 'DX = Cursor Position in Mouse-Screen Rasters',    cr
  635.          db 'DI = Motion Counter (Horizontal)',                cr
  636.          db 'SI = Motion Counter (Vertical)',                  cr
  637.          db                                                    cr
  638.          db 'This function should only be used by experienced',cr
  639.          db 'programmers. The user subroutine is called at',   cr
  640.          db 'interrupt level from the mouse driver with',      cr
  641.          db 'interrupts enabled. This means that mouse ints',  cr
  642.          db 'will occur while your subroutine is active.',     cr
  643.          db 'The driver will not recursively call your',       cr
  644.          db 'subroutine, but you must exercise caution when',  cr
  645.          db 'calling mouse functions from your subroutine due',cr
  646.          db 'to the possibility of changing internal driver',  cr
  647.          db 'data. Remember also that DOS is not reentrant!',  null
  648.  
  649. XFUNC25  db 'Func 25 (Advanced) Read Alt Subroutine Vector',   cr
  650.          db '---------------------------------------------',   cr
  651.          db 'Call:  AX =25',                                   cr
  652.          db '       CX =Alternate Event Mask, bits 5,6,7 only',cr
  653.          db                                                    cr
  654.          db 'Return:AX = -1 if Alt Subroutine Pointer is null',cr
  655.          db '       BX = Segment of Far Ptr to Alt Subroutine',cr
  656.          db '       CX = Alternate Event Mask',                cr
  657.          db '       DX = Offset of Far Ptr to Alt Subroutine', cr
  658.          db                                                    cr
  659.          db 'This function is used to read the alternate sub', cr
  660.          db 'vectors when a pop-up program wants to save the', cr
  661.          db 'state of the vectors prior to defining its own.', cr
  662.          db 'If AX = -1 then the particular vector requested', cr
  663.          db 'is undefined.',                                   null
  664.  
  665. XFUNC26  db '   Function 26 (Advanced) Set Scaling Factors',   cr
  666.          db '   ------------------------------------------',   cr
  667.          db 'Call:    AX = 26',                                cr
  668.          db '         BX = Horizontal Scaling (1 to 100)',     cr
  669.          db '         CX = Vertical Scaling (1 to 100)',       cr
  670.          db '         DX = Double Speed Scaling (1 to 100)',   cr
  671.          db 'Return:  None',                                   cr
  672.          db                                                    cr
  673.          db 'If a scaling factor = 0, then that argument will',cr
  674.          db 'not be changed.The mouse driver converts scaling',cr
  675.          db 'factors to the nearest multiple of five. If 1 is',cr
  676.          db 'entered the driver converts that to 0 so the',    cr
  677.          db 'minimum scaling factor is achieved. This func',   cr
  678.          db 'alters the effective mouse sensitivity. H and V', cr
  679.          db 'Sensitivity settings control the ratio between',  cr
  680.          db 'Mouse-counts and the value that is processed by', cr
  681.          db 'the driver to move the cursor.  As you increase', cr
  682.          db 'the sensitivity, the number of Mickeys processed',cr
  683.          db 'for a given displacement of the mouse increases.',cr
  684.          db 'The Mouse becomes more responsive as the',        cr
  685.          db 'sensitivity increases.',                          cr
  686.          db '                      << press ENTER for MORE >>',lf
  687.  
  688. XFUNC26A db 'The Double Speed Sensitivity is also altered by', cr
  689.          db 'its own scaling factor. Increasing the scaling',  cr
  690.          db 'factor means that the mouse must be moved faster',cr
  691.          db 'in order to exceed the threshold.',               cr
  692.          db                                                    cr
  693.          db 'The responsiveness of the mouse is controlled by',cr
  694.          db 'Function 26 and Functions 15 and 19 working in',  cr
  695.          db 'parallel. The values set by Functions 15 and 19', cr
  696.          db 'are restored tn their default values by a Func 0',cr
  697.          db 'driver reset but not Func 26 Sensitivity.',       cr
  698.          db                                                    cr
  699.          db 'The default Scaling Factor for all three',        cr
  700.          db 'quantities is 50, a number that does not alter',  cr
  701.          db 'the raw mouse-counts. A factor Of 70 approx.',    cr
  702.          db 'doubles the counts while 30 approx. halves them.',null
  703.  
  704. XFUNC27  db '     Function 27 (Advanced)  Get Scaling Factors',cr
  705.          db '     -------------------------------------------',cr
  706.          db 'Call:  AX =27',                                   cr
  707.          db                                                    cr
  708.          db 'Return:BX =Horizontal Scaling Factor (0 to 100)', cr
  709.          db '       CX =Vertical Scaling Factor (0 to 100)',   cr
  710.          db '       DX =DoubleSpeed Threshold Scaling Factor', cr
  711.          db '            (0 to 100)',                          null
  712.  
  713. XFUNC28  db '        Function 28    Reserved',                 cr
  714.          db '        -----------------------',                 null
  715.  
  716. XFUNC29  db 'Function 29 (Advanced)  Set Active Display Page', cr
  717.          db '-----------------------------------------------', cr
  718.          db 'Call:      AX = 29',                              cr
  719.          db '           BX = Active Display Page',             cr
  720.          db                                                    cr
  721.          db 'Return:    None',                                 cr
  722.          db                                                    cr
  723.          db 'Applications that work with multiple display',    cr
  724.          db 'pages need to inform the mouse driver about',     cr
  725.          db 'the active display page so that the mouse cursor',cr
  726.          db 'can be maintained.',                              null
  727.  
  728. XFUNC30  db 'Function 30 (Advanced)  Get Active Display Page', cr
  729.          db '-----------------------------------------------', cr
  730.          db 'Call:      AX = 30',                              cr
  731.          db                                                    cr
  732.          db 'Return:    BX = Active Display Page',             null
  733.  
  734. XFUNC31  db '   Function 31 (Advanced) Disable Mouse Driver',  cr
  735.          db '   -------------------------------------------',  cr
  736.          db 'Call:   AX = 31',                                 cr
  737.          db                                                    cr
  738.          db 'Return: AX = -1 if error',                        cr
  739.          db '        BX = Offset of the old Int 33h Mouse',    cr
  740.          db '             Vector prior to the installation',   cr
  741.          db '             of the mouse driver.',               cr
  742.          db                                                    cr
  743.          db 'The old Mouse Vector is defined by the ES:BX',    cr
  744.          db 'register pair. This function attempts to unhook', cr
  745.          db 'the mouse driver Int 10h stub and mouse hdware',  cr
  746.          db 'interrupt vector.  If there is no error, it',     cr
  747.          db 'then disables the mouse hardware interrupt and',  cr
  748.          db 'returns the old mouse vector so an application',  cr
  749.          db 'can restore the vector if desired. Usually the',  cr
  750.          db 'old mouse vector Points to a null handler in',    cr
  751.          db 'the BIOS or to 0000:0000. This function will',    cr
  752.          db 'return an error if it cannot unhook its vectors', cr
  753.          db 'due to an intervening stub by another resident',  cr
  754.          db 'program. Check for an error return value!!!',     null
  755.  
  756. XFUNC32  db '   Function 32 (Advanced)  Enable Mouse Driver',  cr
  757.          db '   -------------------------------------------',  cr
  758.          db                                                    cr
  759.          db 'Call:      AX = 32',                              cr
  760.          db                                                    cr
  761.          db 'Return:    None',                                 cr
  762.          db                                                    cr
  763.          db 'This function re-enables the driver and re-hooks',cr
  764.          db 'Int 10h and hdwre interrupt vectors if necessary',null
  765.  
  766. XFUNC33  db '        Function 33 Software Reset',              cr
  767.          db '        --------------------------',              cr
  768.          db                                                    cr
  769.          db 'Call:      AX = 33',                              cr
  770.          db                                                    cr
  771.          db 'Return:    AX =  -1 if driver is installed',      cr
  772.          db '           BX =  2(the number of mouse buttons)', cr
  773.          db                                                    cr
  774.          db 'This function is similar to Function 0 but does', cr
  775.          db 'not Configure the mouse port. Note the',          cr
  776.          db 'inconsistent use of AX = -1 to indicate a',       cr
  777.          db 'successful return.',                              null
  778.  
  779. XFUNC34  db '         Function 34 Set Language Byte',          cr
  780.          db '         -----------------------------',          cr
  781.          db 'Call:      AX = 34',                              cr
  782.          db '           BX = Language number',                 cr
  783.          db                                                    cr
  784.          db 'Number  Language',                                cr
  785.          db '----------------',                                cr
  786.          db '  0       English',                               cr
  787.          db '  I       French',                                cr
  788.          db '  2       Dutch',                                 cr
  789.          db '  3       German',                                cr
  790.          db '  4       Swedish',                               cr
  791.          db '  5       Finnish',                               cr
  792.          db '  6       Spanish',                               cr
  793.          db '  7       Portugese',                             cr
  794.          db '  8       Italian',                               cr
  795.          db                                                    cr
  796.          db 'Return:   None',                                  cr
  797.          db                                                    cr
  798.          db 'This function stores a byte value that is',       cr
  799.          db 'interpreted by certain Microsoft utilities to',   cr
  800.          db 'set the language used.',                          null
  801.  
  802. XFUNC35  db '        Function 35 Read Language Byte',          cr
  803.          db '        ------------------------------',          cr
  804.          db 'Call:      AX = 35',                              cr
  805.          db                                                    cr
  806.          db 'Return:    BX = Language Byte',                   cr
  807.          db                                                    cr
  808.          db 'This function returns the Language Byte',         cr
  809.          db 'that was set by Function 34',                     null
  810.  
  811. XFUNC36  db '        Function 36 get Mouse and Driver Data',   cr
  812.          db '        -------------------------------------',   cr
  813.          db 'Call:      AX = 36',                              cr
  814.          db                                                    cr
  815.          db 'Return:    BX = Driver version (in BCD)',         cr
  816.          db '           CX = Interface Type in high byte',     cr
  817.          db '                           IRQ # in low byte.',   cr
  818.          db                                                    cr
  819.          db 'This function returns information about version', cr
  820.          db 'of the mouse driver and the type of mouse.',      cr
  821.          db 'The driver version is the level of Microsoft',    cr
  822.          db 'driver that the mouse driver is compatible with.',cr
  823.          db 'The version bytes are in Binary-Coded Decimal',   cr
  824.          db '(BCD) format. The high byte is the integer part', cr
  825.          db 'and the low byte is the decimal part of the',     cr
  826.          db 'version number. The interface type returned in',  cr
  827.          db 'CX high byte is interpreted as follows:',         cr
  828.          db                                                    cr
  829.          db '                   1 = 8255-based bus mouse',     cr
  830.          db '                   2 = serial mouse',             cr
  831.          db '                   3 = inport bus mouse',         cr
  832.          db '                   4 = PS/2-style mouse port',    null
  833.  
  834. ;
  835. ;-----------------------------------------------------------------------------
  836. ;Front-end routine for the keyboard interrupt handler.  Execution is vectored
  837. ;here whenever an interrupt 9 is generated by the PC keyboard.
  838. ;-----------------------------------------------------------------------------
  839. mikview       proc near
  840.               cmp int_status,0              ;already displayed?
  841.               jne short_exit                ;yes, then exit immediately
  842.               sti                           ;enable interrupts
  843.               push ax                       ;save registers
  844.               push bx
  845.               push cx
  846.               push dx
  847.               push si
  848.               push di
  849.               push ds
  850.               push es
  851.               in al,kb_data                 ;get scan code from keyboard
  852.               cmp al,m_key                  ;was the 'M' key pressed?
  853.               jne exit                      ;no, then exit to normal routine
  854.               mov ah,2                      ;get state of shift keys
  855.               int 16h
  856.               test al,alt_key               ;is the Alt key depressed?
  857.               jne mik1                      ;yes, then continue
  858. ;
  859. ;Exit is achieved thru here when execution is to be transferred to the normal
  860. ;BIOS keyboard interrupt handling routine.
  861. ;
  862. exit:         pop es                        ;restore registers
  863.               pop ds
  864.               pop di
  865.               pop si
  866.               pop dx
  867.               pop cx
  868.               pop bx
  869.               pop ax
  870. short_exit:   jmp old_int_9h                ;goto BIOS keyboard routine
  871. ;
  872. ;The key combination Alt-M was just pressed.  Reset the keyboard and issue an
  873. ;EOI to the 8259 PIC to enable hardware interrupts.
  874. ;
  875. mik1:         call kb_reset               ;reset keyboard, end 8259 int
  876.               push cs                     ;set DS and ES to the code segment
  877.               pop ds
  878.               push cs
  879.               pop es
  880.               assume ds:code
  881. ;
  882. ;Check the current video mode to see if it's one of the 80-column text modes
  883. ;(2, 3, or 7).  If it is, then continue.  If it's not, gracefully abort this
  884. ;routine by exiting thru an IRET.
  885. ;
  886.               mov ah,15                     ;get video page and display mode
  887.               int 10h
  888.               cmp al,2                      ;video mode 2?
  889.               je mik2                       ;yes, then continue
  890.               cmp al,3                      ;mode 3?
  891.               je mik2                       ;yes, then continue
  892.               cmp al,7                      ;mode 7 (monochrome)?
  893.               je mik2                       ;yes, then continue
  894. done:         pop es                        ;restore register values for exit
  895.               pop ds
  896.               pop di
  897.               pop si
  898.               pop dx
  899.               pop cx
  900.               pop bx
  901.               pop ax
  902.               iret                          ;return to interrupted program
  903. ;
  904. ;Save the current video page number and the cursor scan line parameters,
  905. ;set the interrupt routine status flag, and blank the cursor.
  906. ;
  907. mik2:         mov video_page,bh             ;save page number
  908.               mov int_status,1              ;set interrupt routine status flag
  909.               mov ah,3                      ;get the cursor shape
  910.               int 10h
  911.               mov cursor_mode,cx            ;save it
  912.               mov ah,1                      ;hide the cursor for now
  913.               mov ch,20h
  914.               int 10h
  915. ;
  916. ;Save the contents of the portion of the Qareen beneath the window.
  917. ;
  918.               cmp adapter,0                 ;is this a CGA?
  919.               jne mik3                      ;no, then skip disable
  920.               call disable_cga              ;disable CGA video
  921. mik3:         mov di,screen_buffer          ;point DI to storage buffer
  922.               call save_screen              ;save screen contents
  923. ;
  924. ;Pop the window border onto the display by writing directly to video.  Finish
  925. ;things up by filling the blank window the first of the mouse functions
  926. ;
  927.               call open_window              ;pop up the window border
  928.               cmp adapter,0                 ;is this a CGA?
  929.               jne mik4                      ;no, then skip enable
  930.               call enable_cga               ;enable CGA video
  931. mik4:         mov start_value,0             ;reset the index pointers
  932.               mov func_index,0
  933.               mov old_index, 255
  934.               call fill_window              ;write the window text
  935. ;
  936. ;The window is now displayed on the screen.  Wait for a keypress.
  937. ;
  938. mik5:         mov ah,0                      ;get a keypress
  939.               int 16h
  940.               cmp al,0                      ;is it an extended code?
  941.               je mik10                      ;yes, then jump
  942.               cmp al,27                     ;ESC key pressed?
  943.               je  get_lost
  944.               cmp al,13                     ;Enter Key Pressed
  945.               jne mik5                      ;no, then get another keypress
  946.  
  947.               mov al, func_index            ;skip the explanation
  948.               cmp al, old_index
  949.               je skip_explanation
  950.               mov old_index, al
  951.  
  952.               call clear_explanation        ;or clear the old explanation
  953.  
  954.               mov dh, window_row            ;now print the explanation
  955.               add dh, 2
  956.               mov dl, window_column
  957.               add dl, 31
  958.               mov al, func_index
  959.               call func_explain
  960.  
  961. skip_explanation:
  962.               jmp mik5                      ;return for another key press
  963.  
  964. get_lost:
  965. ;
  966. ;The ESC key has been pressed.  Restore the original contents of the screen,
  967. ;restore the cursor, reset the status flag, and exit to the application.
  968. ;
  969.               cmp adapter,0                 ;blank video if CGA installed
  970.               jne mik6
  971.               call disable_cga
  972. mik6:         mov si,screen_buffer          ;point SI to holding buffer
  973.               call restore_screen           ;restore video memory contents
  974.               cmp adapter,0                 ;enable video if necessary
  975.               jne mik7
  976.               call enable_cga
  977. mik7:         mov ah,1                      ;unblank the cursor
  978.               mov cx,cursor_mode            ;define cursor scan lines
  979.               int 10h
  980.               mov int_status,0              ;reset status flag
  981.               jmp done                      ;exit
  982. ;
  983. ;A key has been pressed that returned an extended code.
  984. ;
  985. mik10:        cmp ah,72                     ;Up-Arrow pressed?
  986.               jne mik11                     ;no, then jump to next test
  987.               call scroll_down              ;yes, then scroll down
  988.               jmp mik5                      ;return for another keypress
  989. mik11:        cmp ah,80                     ;Down-Arrow pressed?
  990.               jne mik12
  991.               call scroll_up                ;scroll window up
  992.               jmp mik5
  993. mik12:        cmp ah,73                     ;PgUp pressed?
  994.               jne mik13
  995.               call last_window_page         ;flip window page back
  996.               jmp mik5
  997. mik13:        cmp ah,81                     ;PgDn pressed?
  998.               jne mik14
  999.               call next_window_page         ;flip window page forward
  1000.               jmp mik5
  1001. mik14:        cmp ah,79                     ;End pressed?
  1002.               jne mik15
  1003.               call end_window_page          ;flip to last window page
  1004.               jmp mik5
  1005. mik15:        cmp ah,71                     ;Home pressed?
  1006.               jne mik16                     ;no, then start again
  1007.               call first_window_page        ;goto first window page
  1008. mik16:        jmp mik5                      ;look for another keypress
  1009. mikview       endp
  1010. ;
  1011. ;-----------------------------------------------------------------------------
  1012. ;SAVE_SCREEN saves the contents of the screen beneath the window.
  1013. ;Entry:  ES:DI - buffer address
  1014. ;-----------------------------------------------------------------------------
  1015. save_screen   proc near
  1016.               mov dh,window_row             ;row and column of window corner
  1017.               mov dl,window_column
  1018.               mov bl,video_page             ;get video page in BX
  1019.               xor bh,bh
  1020.               push di                       ;save buffer address
  1021.               call video_offset             ;get starting address of window
  1022.               mov si,di                     ;transfer address to SI
  1023.               pop di                        ;retrieve buffer address
  1024.               push ds                       ;save DS
  1025.               mov ds,video_segment          ;set DS to video segment
  1026.               assume ds:nothing
  1027.               mov cx,25                     ;25 lines to save
  1028.               cld                           ;clear DF
  1029. save1:        push cx                       ;save line counter
  1030.               mov cx,80                     ;80 words per line
  1031.               rep movsw                     ;transfer one line to buffer
  1032.               pop cx                        ;get line count
  1033.               loop save1                    ;loop until done
  1034.               pop ds                        ;restore DS
  1035.               assume ds:code
  1036.               ret
  1037. save_screen   endp
  1038. ;
  1039. ;-----------------------------------------------------------------------------
  1040. ;RESTORE_SCREEN restores the contents of the screen beneath the window.
  1041. ;Entry:  DS:SI - buffer address
  1042. ;-----------------------------------------------------------------------------
  1043. restore_screen proc near
  1044.               mov dh,window_row             ;row & column where window starts
  1045.               mov dl,window_column
  1046.               mov bl,video_page             ;get video page in BX
  1047.               xor bh,bh
  1048.               call video_offset             ;get window starting address
  1049.               mov es,video_segment          ;set ES to video segment
  1050.               mov cx,25                     ;25 lines to restore
  1051.               cld                           ;clear DF
  1052. restore1:     push cx                       ;save line counter
  1053.               mov cx,80                     ;80 words per line
  1054.               rep movsw                     ;restore one line
  1055.               pop cx                        ;retrieve count
  1056.               loop restore1                 ;loop until done
  1057.               ret
  1058. restore_screen endp
  1059. ;
  1060. ;-----------------------------------------------------------------------------
  1061. ;VIDEO_OFFSET calculates the offset address in video memory that corresponds
  1062. ;to the given row, column, and video page.
  1063. ;Entry:  DH,DL - row, column           | Exit:  DI - offset
  1064. ;        BX    - video page            |
  1065. ;-----------------------------------------------------------------------------
  1066. video_offset  proc near
  1067.               mov al,160                    ;row * 160
  1068.               mul dh                        ;result in AX
  1069.               shl dl,1                      ;column * 2
  1070.               xor dh,dh                     ;byte to word in DX
  1071.               add ax,dx                     ;add the two
  1072.               mov di,ax                     ;save result in DI
  1073.               mov ax,1000h                  ;length of one video page
  1074.               mul bx                        ;page * 1000h
  1075.               add di,ax                     ;complete the offset address
  1076.               ret
  1077. video_offset  endp
  1078. ;
  1079. ;-----------------------------------------------------------------------------
  1080. ;DISABLE_CGA and ENABLE_CGA routines disable and enable CGA video by writing
  1081. ;to the Mode Select Register at port address 3D8h.
  1082. ;-----------------------------------------------------------------------------
  1083. disable_cga   proc near
  1084.               mov dx,3DAh                   ;load Status Register address
  1085. disable1:     in al,dx                      ;get video status
  1086.               test al,8                     ;vertical retrace active?
  1087.               je disable1                   ;no, then wait until it is
  1088.               sub dx,2                      ;load MSR address
  1089.               mov al,25h                    ;value to disable video
  1090.               out dx,al                     ;send it to the adapter
  1091.               ret
  1092. disable_cga   endp
  1093. ;
  1094. enable_cga    proc near
  1095.               mov ah,15                     ;get current video mode
  1096.               int 10h
  1097.               lea bx,enable_values          ;offset of enable value table
  1098.               xlat                          ;get the value to enable video
  1099.               mov dx,3D8h                   ;load address of MSR
  1100.               out dx,al                     ;OUT the enable value
  1101.               ret
  1102. enable_cga    endp
  1103. ;
  1104. ;-----------------------------------------------------------------------------
  1105. ;KB_RESET resets the keyboard and issues an EOI to the 8259 PIC.
  1106. ;-----------------------------------------------------------------------------
  1107. kb_reset      proc near
  1108.               in al,kb_ctrl                 ;get current control port value
  1109.               mov ah,al                     ;save it in AH
  1110.               or al,80h                     ;set bit 7
  1111.               out kb_ctrl,al                ;send reset value
  1112.               mov al,ah                     ;get original value
  1113.               out kb_ctrl,al                ;send it out to enable keyboard
  1114.               cli                           ;suspend interrupts
  1115.               mov al,eoi                    ;get EOI value
  1116.               out int_ctrl_port,al          ;send EOI to 8259
  1117.               sti                           ;enable interrupts
  1118.               ret
  1119. kb_reset      endp
  1120. ;
  1121. ;-----------------------------------------------------------------------------
  1122. ;OUTPUT_CHAR writes the designated character directly to video memory.
  1123. ;Entry:  DH,DL - row, column
  1124. ;        AH,AL - attribute, character
  1125. ;-----------------------------------------------------------------------------
  1126. output_char   proc near
  1127.               push dx                       ;save DX and AX
  1128.               push ax
  1129.               mov bl,video_page             ;get page in BX
  1130.               xor bh,bh
  1131.               call video_offset             ;calculate address to write to
  1132.               cmp adapter,0                 ;is this a CGA?
  1133.               jne output3                   ;no, then skip wait loop
  1134.               mov dx,3DAh                   ;get CGA Status Register address
  1135. output1:      in al,dx                      ;wait until horiz. retrace done
  1136.               test al,1
  1137.               jne output1
  1138.               cli                           ;suspend interrupts during write
  1139. output2:      in al,dx                      ;wait for next horizontal retrace
  1140.               test al,1
  1141.               je output2
  1142. output3:      pop ax                        ;get character and attribute
  1143.               stosw                         ;write them to video memory
  1144.               sti                           ;enable interrupts
  1145.               pop dx                        ;restore DX
  1146.               ret
  1147. output_char   endp
  1148. ;
  1149. ;-----------------------------------------------------------------------------
  1150. ;FILL_WINDOW writes the text of the mouse function table to the window.
  1151. ;-----------------------------------------------------------------------------
  1152. fill_window   proc near
  1153.  
  1154.               mov dh,window_row             ;set DH for first text row
  1155.               add dh,2
  1156.  
  1157.               mov cx,16                     ;16 lines to fill
  1158. fill1:        push cx                       ;save line counter
  1159.               mov dl,window_column          ;specify starting column
  1160.               add dl,1
  1161.               mov al,start_value;
  1162.               call write_line
  1163.               inc dh                        ;set cursor for next row
  1164.               inc start_value;
  1165.               mov al,start_value;
  1166.               pop cx                        ;retrieve line counter
  1167.               loop fill1                    ;loop until table full
  1168.               ret
  1169. fill_window   endp
  1170.  
  1171. ;-----------------------------------------------------------------------------
  1172. ;WRITE_TITLE outputs the title block
  1173. ;        DH,DL - row, column to start writing at
  1174. ;-----------------------------------------------------------------------------
  1175. ;
  1176. ; explain the current mouse function
  1177. ;
  1178. write_title proc near
  1179.               mov es,video_segment          ;set ES to video for writing
  1180.               lea si,titleblock             ;point SI to text of line
  1181.               push cx
  1182.               mov dh,window_row
  1183.               add dh,18
  1184.               mov dl,window_column
  1185.               add dl,1
  1186.               mov ah,border_attr            ;use border attribute first
  1187. title_again:                                ;get the text character
  1188.               mov al,byte ptr[si]
  1189.               cmp al,0                      ;if its a zero return
  1190.               je title_clear
  1191.               lodsb
  1192.               cmp al,cr                     ;if its not a carriage return
  1193.               je title_return
  1194.               call output_char              ;print the chracter
  1195.               inc dl                        ;advance cursor
  1196.               jmp title_again
  1197.  
  1198. title_return: inc dh                        ;do a hard return
  1199.               mov dl,window_column          ;and make another pass
  1200.               add dl,1
  1201.               mov ah, title_attr
  1202.               jmp title_again
  1203. title_clear:
  1204.               mov dh, window_row            ;now print the int info
  1205.               add dh, 2
  1206.               mov dl, window_column
  1207.               add dl, 31
  1208.               mov al, 255
  1209.               call func_explain
  1210.  
  1211.               pop cx
  1212.               ret
  1213. write_title  endp
  1214.  
  1215.  
  1216. ;
  1217. ;-----------------------------------------------------------------------------
  1218. ;WRITE_LINE outputs the description of the current mouse function.
  1219. ;Entry:  AL    - index value for mouse function
  1220. ;        DH,DL - row, column to start writing at
  1221. ;-----------------------------------------------------------------------------
  1222. write_line    proc near
  1223.               mov es,video_segment          ;set ES to video for writing
  1224.               cmp al,0
  1225.               jne first
  1226.               lea si,FUNC00                 ;point SI to text of line
  1227.               jmp print_here
  1228. first:        cmp al,1
  1229.               jne second
  1230.               lea si,FUNC01
  1231.               jmp print_here
  1232. second:       cmp al,2
  1233.               jne third
  1234.               lea si,FUNC02
  1235.               jmp print_here
  1236. third:        cmp al,3
  1237.               jne fourth
  1238.               lea si,FUNC03
  1239.               jmp print_here
  1240. fourth:       cmp al,4
  1241.               jne fifth
  1242.               lea si,FUNC04
  1243.               jmp print_here
  1244. fifth:        cmp al,5
  1245.               jne sixth
  1246.               lea si,FUNC05
  1247.               jmp print_here
  1248. sixth:        cmp al,6
  1249.               jne seventh
  1250.               lea si,FUNC06
  1251.               jmp print_here
  1252. seventh:      cmp al,7
  1253.               jne eighth
  1254.               lea si,FUNC07
  1255.               jmp print_here
  1256. eighth:       cmp al,8
  1257.               jne ninth
  1258.               lea si,FUNC08
  1259.               jmp print_here
  1260. ninth:        cmp al,9
  1261.               jne tenth
  1262.               lea si,FUNC09
  1263.               jmp print_here
  1264. tenth:        cmp al,10
  1265.               jne eleventh
  1266.               lea si,FUNC10
  1267.               jmp print_here
  1268. eleventh:     cmp al,11
  1269.               jne twelfth
  1270.               lea si,FUNC11
  1271.               jmp print_here
  1272. twelfth:      cmp al,12
  1273.               jne thirteen
  1274.               lea si,FUNC12
  1275.               jmp print_here
  1276. thirteen:     cmp al,13
  1277.               jne fourteen
  1278.               lea si,FUNC13
  1279.               jmp print_here
  1280. fourteen:     cmp al,14
  1281.               jne fifteen
  1282.               lea si,FUNC14
  1283.               jmp print_here
  1284. fifteen:      cmp al,15
  1285.               jne sixteen
  1286.               lea si,FUNC15
  1287.               jmp print_here
  1288. sixteen:      cmp al,16
  1289.               jne seventeen
  1290.               lea si,FUNC16
  1291.               jmp print_here
  1292. seventeen:    cmp al,17
  1293.               jne eighteen
  1294.               lea si,FUNC17
  1295.               jmp print_here
  1296. eighteen:     cmp al,18
  1297.               jne nineteen
  1298.               lea si,FUNC18
  1299.               jmp print_here
  1300. nineteen:     cmp al,19
  1301.               jne twenty
  1302.               lea si,FUNC19
  1303.               jmp print_here
  1304. twenty:       cmp al,20
  1305.               jne twentyone
  1306.               lea si,FUNC20
  1307.               jmp print_here
  1308. twentyone:    cmp al,21
  1309.               jne twentytwo
  1310.               lea si,FUNC21
  1311.               jmp print_here
  1312. twentytwo:    cmp al,22
  1313.               jne twentythree
  1314.               lea si,FUNC22
  1315.               jmp print_here
  1316. twentythree:  cmp al,23
  1317.               jne twentyfour
  1318.               lea si,FUNC23
  1319.               jmp print_here
  1320. twentyfour:   cmp al,24
  1321.               jne twentyfive
  1322.               lea si,FUNC24
  1323.               jmp print_here
  1324. twentyfive:   cmp al,25
  1325.               jne twentysix
  1326.               lea si,FUNC25
  1327.               jmp print_here
  1328. twentysix:    cmp al,26
  1329.               jne twentyseven
  1330.               lea si,FUNC26
  1331.               jmp print_here
  1332. twentyseven:  cmp al,27
  1333.               jne twentyeight
  1334.               lea si,FUNC27
  1335.               jmp print_here
  1336. twentyeight:  cmp al,28
  1337.               jne twentynine
  1338.               lea si,FUNC28
  1339.               jmp print_here
  1340. twentynine:   cmp al,29
  1341.               jne thirty
  1342.               lea si,FUNC29
  1343.               jmp print_here
  1344. thirty:       cmp al,30
  1345.               jne thirtyone
  1346.               lea si,FUNC30
  1347.               jmp print_here
  1348. thirtyone:    cmp al,31
  1349.               jne thirtytwo
  1350.               lea si,FUNC31
  1351.               jmp print_here
  1352. thirtytwo:    cmp al,32
  1353.               jne thirtythree
  1354.               lea si,FUNC32
  1355.               jmp print_here
  1356. thirtythree:  cmp al,33
  1357.               jne thirtyfour
  1358.               lea si,FUNC33
  1359.               jmp print_here
  1360. thirtyfour:   cmp al,34
  1361.               jne thirtyfive
  1362.               lea si,FUNC34
  1363.               jmp print_here
  1364. thirtyfive:   cmp al,35
  1365.               jne thirtysix
  1366.               lea si,FUNC35
  1367.               jmp print_here
  1368. thirtysix:    lea si,FUNC36
  1369.  
  1370. print_here:
  1371.               push cx
  1372.               cmp al,func_index
  1373.               je hi_lite
  1374.               mov ah,text_attr              ;otherwise use text attribute
  1375.               jmp goagain
  1376. hi_lite:      mov ah, reverse_attr
  1377. goagain:                                    ;get the text character
  1378.               mov al,byte ptr[si]
  1379.               cmp al,0
  1380.               je print_done
  1381.               lodsb
  1382.               call output_char              ;print the digit
  1383.               inc dl                        ;advance cursor
  1384.               jmp goagain
  1385. print_done:
  1386.               pop cx
  1387.               ret
  1388. write_line    endp
  1389.  
  1390.  
  1391. ;-----------------------------------------------------------------------------
  1392. ;FUNC_EXPLAIN outputs the explanation of the current mouse function.
  1393. ;Entry:  AL    - index value for mouse function
  1394. ;        DH,DL - row, column to start writing at
  1395. ;-----------------------------------------------------------------------------
  1396. ;
  1397. ; explain the current mouse function
  1398. ;
  1399. func_explain proc near
  1400.               mov es,video_segment          ;set ES to video for writing
  1401.               cmp al,255
  1402.               jne dofunc                    ;if its not the int info
  1403.               lea si, XMOUSE                ;then its a function explanation
  1404.               jmp explain_here
  1405. dofunc:
  1406.               cmp al,0
  1407.               jne Xfirst
  1408.               lea si,XFUNC00                 ;point SI to text of line
  1409.               jmp explain_here
  1410. Xfirst:       cmp al,1
  1411.               jne Xsecond
  1412.               lea si,XFUNC01
  1413.               jmp explain_here
  1414. Xsecond:      cmp al,2
  1415.               jne Xthird
  1416.               lea si,XFUNC02
  1417.               jmp explain_here
  1418. Xthird:       cmp al,3
  1419.               jne Xfourth
  1420.               lea si,XFUNC03
  1421.               jmp explain_here
  1422. Xfourth:      cmp al,4
  1423.               jne Xfifth
  1424.               lea si,XFUNC04
  1425.               jmp explain_here
  1426. Xfifth:       cmp al,5
  1427.               jne Xsixth
  1428.               lea si,XFUNC05
  1429.               jmp explain_here
  1430. Xsixth:       cmp al,6
  1431.               jne Xseventh
  1432.               lea si,XFUNC06
  1433.               jmp explain_here
  1434. Xseventh:     cmp al,7
  1435.               jne Xeighth
  1436.               lea si,XFUNC07
  1437.               jmp explain_here
  1438. Xeighth:      cmp al,8
  1439.               jne Xninth
  1440.               lea si,XFUNC08
  1441.               jmp explain_here
  1442. Xninth:       cmp al,9
  1443.               jne Xtenth
  1444.               lea si,XFUNC09
  1445.               jmp explain_here
  1446. Xtenth:       cmp al,10
  1447.               jne Xeleventh
  1448.               lea si,XFUNC10
  1449.               jmp explain_here
  1450. Xeleventh:    cmp al,11
  1451.               jne Xtwelfth
  1452.               lea si,XFUNC11
  1453.               jmp explain_here
  1454. Xtwelfth:     cmp al,12
  1455.               jne Xthirteen
  1456.               lea si,XFUNC12
  1457.               jmp explain_here
  1458. Xthirteen:    cmp al,13
  1459.               jne Xfourteen
  1460.               lea si,XFUNC13
  1461.               jmp explain_here
  1462. Xfourteen:    cmp al,14
  1463.               jne Xfifteen
  1464.               lea si,XFUNC14
  1465.               jmp explain_here
  1466. Xfifteen:     cmp al,15
  1467.               jne Xsixteen
  1468.               lea si,XFUNC15
  1469.               jmp explain_here
  1470. Xsixteen:     cmp al,16
  1471.               jne Xseventeen
  1472.               lea si,XFUNC16
  1473.               jmp explain_here
  1474. Xseventeen:   cmp al,17
  1475.               jne Xeighteen
  1476.               lea si,XFUNC17
  1477.               jmp explain_here
  1478. Xeighteen:    cmp al,18
  1479.               jne Xnineteen
  1480.               lea si,XFUNC18
  1481.               jmp explain_here
  1482. Xnineteen:    cmp al,19
  1483.               jne Xtwenty
  1484.               lea si,XFUNC19
  1485.               jmp explain_here
  1486. Xtwenty:      cmp al,20
  1487.               jne Xtwentyone
  1488.               lea si,XFUNC20
  1489.               jmp explain_here
  1490. Xtwentyone:   cmp al,21
  1491.               jne Xtwentytwo
  1492.               lea si,XFUNC21
  1493.               jmp explain_here
  1494. Xtwentytwo:   cmp al,22
  1495.               jne Xtwentythree
  1496.               lea si,XFUNC22
  1497.               jmp explain_here
  1498. Xtwentythree: cmp al,23
  1499.               jne Xtwentyfour
  1500.               lea si,XFUNC23
  1501.               jmp explain_here
  1502. Xtwentyfour:  cmp al,24
  1503.               jne Xtwentyfive
  1504.               lea si,XFUNC24
  1505.               jmp explain_here
  1506. Xtwentyfive:  cmp al,25
  1507.               jne Xtwentysix
  1508.               lea si,XFUNC25
  1509.               jmp explain_here
  1510. Xtwentysix:   cmp al,26
  1511.               jne Xtwentyseven
  1512.               lea si,XFUNC26
  1513.               jmp explain_here
  1514. Xtwentyseven: cmp al,27
  1515.               jne Xtwentyeight
  1516.               lea si,XFUNC27
  1517.               jmp explain_here
  1518. Xtwentyeight: cmp al,28
  1519.               jne Xtwentynine
  1520.               lea si,XFUNC28
  1521.               jmp explain_here
  1522. Xtwentynine:  cmp al,29
  1523.               jne Xthirty
  1524.               lea si,XFUNC29
  1525.               jmp explain_here
  1526. Xthirty:      cmp al,30
  1527.               jne Xthirtyone
  1528.               lea si,XFUNC30
  1529.               jmp explain_here
  1530. Xthirtyone:   cmp al,31
  1531.               jne Xthirtytwo
  1532.               lea si,XFUNC31
  1533.               jmp explain_here
  1534. Xthirtytwo:   cmp al,32
  1535.               jne Xthirtythree
  1536.               lea si,XFUNC32
  1537.               jmp explain_here
  1538. Xthirtythree: cmp al,33
  1539.               jne Xthirtyfour
  1540.               lea si,XFUNC33
  1541.               jmp explain_here
  1542. Xthirtyfour:  cmp al,34
  1543.               jne Xthirtyfive
  1544.               lea si,XFUNC34
  1545.               jmp explain_here
  1546. Xthirtyfive:  cmp al,35
  1547.               jne Xthirtysix
  1548.               lea si,XFUNC35
  1549.               jmp explain_here
  1550. Xthirtysix:   lea si,XFUNC36
  1551.  
  1552. explain_here:
  1553.               push cx
  1554.               mov ah, header_attr           ;use the reverse color for
  1555.               cmp al,255                    ;the first screen only
  1556.               jne explainagain
  1557.               mov ah, reverse_attr
  1558.  
  1559. explainagain:                               ;get the text character
  1560.               mov al,byte ptr[si]
  1561.               cmp al,0                      ;if its a zero return
  1562.               je all_clear
  1563.               lodsb
  1564.               cmp al,cr                     ;if its not a carriage return
  1565.               je hard_return
  1566.               cmp al,lf
  1567.               je  wait_key
  1568.               call output_char              ;print the character
  1569.               inc dl                        ;advance cursor
  1570.               jmp explainagain
  1571.  
  1572. hard_return:  inc dh                        ;do a hard return
  1573.               mov dl,window_column          ;and make another pass
  1574.               add dl,31
  1575.               jmp explainagain
  1576. wait_key:
  1577.               mov old_index, 255            ;set flags for a wrap
  1578.               mov ah,0                      ;get a keypress
  1579.               int 16h
  1580.               cmp al,13                     ;was enter pressed
  1581.               jne all_clear                 ;no, then all clear
  1582.               call clear_explanation        ;clear the screen
  1583.               mov dh,window_row
  1584.               add dh,2
  1585.               mov dl,window_column          ;and make another pass
  1586.               add dl,31
  1587.               mov ah,header_attr
  1588.               jmp explainagain              ;make another pass
  1589.  
  1590. all_clear:
  1591.               pop cx
  1592.               ret
  1593. func_explain  endp
  1594.  
  1595.  
  1596. ;
  1597. ;-----------------------------------------------------------------------------
  1598. ;OPEN_WINDOW draws the window border onto the screen.  Character/attribute
  1599. ;pairs are sent directly to video memory for fast display speed.
  1600. ;-----------------------------------------------------------------------------
  1601. open_window   proc near
  1602.               mov dh,window_row             ;get coordinates of window corner
  1603.               mov dl,window_column
  1604.               mov es,video_segment          ;point ES to video buffer
  1605.               cld                           ;clear DF for string operations
  1606.               mov bl,video_page             ;get video page in BX
  1607.               xor bh,bh
  1608.               call video_offset             ;calculate starting address
  1609. ;
  1610. ;Write the top line of the window border to video.
  1611. ;
  1612.               mov al,218                    ;start with upper left corner
  1613.               mov ah,border_attr            ;set attribute
  1614.               stosw
  1615.               mov cx,78                     ;do the next 78 characters
  1616.               mov al,196
  1617.               rep stosw
  1618.               mov al,191                    ;do upper right corner
  1619.               stosw
  1620. ;
  1621. ;Do the window header line.
  1622. ;
  1623.               mov al,179                    ;left window border character
  1624.               stosw                         ;write it
  1625.               lea si,header_text            ;point SI to text of line
  1626.               mov cx,28                     ;28 characters to write
  1627.               mov ah,header_attr            ;use header attribute for these
  1628. open1:        lodsb                         ;get the text character
  1629.               stosw                         ;write char/attr pair to video
  1630.               loop open1                    ;repeat for all 27
  1631.  
  1632.               mov ah,border_attr
  1633.               mov cx,50                     ;next 50 characters
  1634.               mov al,196
  1635.               rep stosw
  1636.               mov ah,border_attr            ;do rightmost column
  1637.               mov al,179
  1638.               stosw
  1639. ;
  1640. ;Now write the next 22 lines (no text) to the display.
  1641. ;
  1642.               mov cx,22                     ;22 lines to do
  1643. open2:        push cx                       ;save line counter
  1644.               mov al,179                    ;do leftmost column
  1645.               mov ah,border_attr
  1646.               stosw
  1647.               mov al,32                     ;do next 28 columns (blank)
  1648.               mov ah,text_attr
  1649.               mov cx,28
  1650.               rep stosw
  1651.               mov ah,border_attr
  1652.               mov al,179
  1653.               stosw
  1654.               mov ah,reverse_attr
  1655.               mov al,32
  1656.               mov cx,49
  1657.               rep stosw
  1658.               mov al,179                    ;do rightmost column
  1659.               mov ah,border_attr
  1660.               stosw
  1661.               pop cx                        ;retrieve counter
  1662.               loop open2                    ;loop until finished
  1663. ;
  1664. ;Finish things up by writing the last line.
  1665. ;
  1666.               mov al,192                    ;lower left corner
  1667.               stosw
  1668.               mov cx,78                     ;next 78 characters
  1669.               mov al,196
  1670.               rep stosw
  1671.               mov al,217                    ;lower right corner
  1672.               stosw
  1673. ;
  1674. ;now write the title
  1675. ;
  1676.               call write_title
  1677.               ret
  1678. open_window   endp
  1679.  
  1680. ;
  1681. ;-----------------------------------------------------------------------------
  1682. ;CLEAR_EXPLANATION clears the explanation box.
  1683. ;-----------------------------------------------------------------------------
  1684. clear_explanation   proc near
  1685.               mov es,video_segment          ;point ES to video buffer
  1686.               mov al,32
  1687.               mov ah, border_attr           ;use border attribute for these
  1688.               mov dl, window_column
  1689.               add dl, 30
  1690.               mov dh, window_row
  1691.               add dh, 2
  1692.               push cx
  1693. outerloop:    mov  cx, 49
  1694. innerloop:                                  ;get the text character
  1695.               call output_char              ;print the digit
  1696.               inc dl                        ;advance cursor
  1697.               loop innerloop                ;repeat for all 48
  1698.               inc dh
  1699.               cmp dh,24
  1700.               je endof_loop                  ;do a hard return
  1701.               mov dl,window_column          ;and make another pass
  1702.               add dl,30
  1703.               jmp outerloop
  1704. endof_loop:
  1705.               pop cx
  1706.               ret
  1707. clear_explanation endp
  1708.  
  1709. ;
  1710. ;-----------------------------------------------------------------------------
  1711. ;SCROLL_UP scrolls the window contents up one line.
  1712. ;-----------------------------------------------------------------------------
  1713. scroll_up     proc near
  1714.               cmp func_index,36
  1715.               je scrlup0
  1716.               inc func_index
  1717.  
  1718.               sub start_value,15    ;subtract 15 from start value
  1719. scrlup0:
  1720.               cmp start_value,21    ;are we at the top yet
  1721.               jb scrlup1            ;otherwise we are still ok
  1722.               mov start_value,21;
  1723. scrlup1:
  1724.               call fill_window;
  1725.               ret
  1726. scroll_up     endp
  1727. ;
  1728. ;-----------------------------------------------------------------------------
  1729. ;SCROLL_DOWN scrolls the window contents down one line.
  1730. ;-----------------------------------------------------------------------------
  1731. scroll_down   proc near
  1732.               cmp func_index,0
  1733.               je scrldn0
  1734.               dec func_index
  1735. scrldn0:
  1736.               cmp start_value,17
  1737.               jb scrldn1
  1738.               sub start_value,17
  1739.               ja scrldn2
  1740. scrldn1:
  1741.               mov start_value,0
  1742. scrldn2:
  1743.               call fill_window;
  1744.               ret
  1745. scroll_down   endp
  1746. ;
  1747. ;-----------------------------------------------------------------------------
  1748. ;LAST_WINDOW_PAGE pages the window back one page.
  1749. ;-----------------------------------------------------------------------------
  1750. last_window_page proc near
  1751.               cmp func_index, 16
  1752.               jb last
  1753.               sub func_index, 16
  1754.               jmp last0
  1755. last:         mov func_index, 0
  1756. last0:
  1757.               cmp start_value,32
  1758.               jb last1
  1759.               sub start_value,32
  1760.               ja last2
  1761. last1:
  1762.               mov start_value,0
  1763. last2:
  1764.               call fill_window              ;write the new page
  1765.               ret
  1766. last_window_page endp
  1767. ;
  1768. ;-----------------------------------------------------------------------------
  1769. ;NEXT_WINDOW_PAGE pages the window forward one page.
  1770. ;-----------------------------------------------------------------------------
  1771. next_window_page proc near
  1772.               add func_index, 16
  1773.               cmp func_index, 36
  1774.               jb  next0
  1775.               mov func_index, 36
  1776. next0:        cmp start_value,21
  1777.               jb next1                      ;yes, then jump
  1778.               mov start_value,21            ;otherwise do the last page
  1779. next1:
  1780.               call fill_window              ;write new text page
  1781.               ret
  1782. next_window_page endp
  1783. ;
  1784. ;-----------------------------------------------------------------------------
  1785. ;FIRST_WINDOW_PAGE flips the window contents to the first page.
  1786. ;-----------------------------------------------------------------------------
  1787. first_window_page proc near
  1788.               mov func_index, 0
  1789.               mov start_value,0
  1790.               call fill_window              ;write text to window
  1791. first1:       ret
  1792. first_window_page endp
  1793. ;
  1794. ;-----------------------------------------------------------------------------
  1795. ;END_WINDOW_PAGE flips the window contents to the final page.
  1796. ;-----------------------------------------------------------------------------
  1797. end_window_page proc near
  1798.               mov func_index, 36
  1799.               mov start_value,21
  1800.               call fill_window              ;write window text
  1801. end1:         ret
  1802. end_window_page endp
  1803.  
  1804. ;-----------------------------------------------------------------------------
  1805. ;LIST$ writes a string to stdout
  1806. ;-----------------------------------------------------------------------------
  1807. list$ proc near
  1808.       push ax
  1809.       mov ah,9h ; call dos function 9H
  1810.       int 21h
  1811.       pop ax
  1812.       ret
  1813. list$ endp
  1814.  
  1815. ;-----------------------------------------------------------------------------
  1816. ;INITIALIZE performs a variety of tasks to set the stage for the resident part
  1817. ;of the program.
  1818. ;-----------------------------------------------------------------------------
  1819. initialize    proc near
  1820. ;
  1821. ;See if the display adapter is an EGA by looking for the EGA BIOS signature.
  1822. ;
  1823.               mov ax,0C000h                 ;set ES to EGA BIOS segment
  1824.               mov es,ax
  1825.               mov di,1Eh                    ;point DI to signature location
  1826.               lea si,ibm_signature          ;point SI to 'IBM' text
  1827.               mov cx,3                      ;three bytes to compare
  1828.               cld                           ;clear DF
  1829.               repe cmpsb                    ;check three bytes
  1830.               je init1                      ;jump if EGA signature found
  1831. ;
  1832. ;The display adapter is not an EGA.  Determine whether it's a CGA or an MDA.
  1833. ;
  1834.               mov adapter,0                 ;zero ADAPTER for CGA
  1835.               mov ah,15                     ;get video mode
  1836.               int 10h
  1837.               cmp al,7                      ;is it mode 7?
  1838.               jne init1                     ;no, then it's a CGA - jump
  1839.               inc adapter                   ;yes, it's an MDA - set ADAPTER
  1840. ;
  1841. ;If this is a monochrome system, modify color-dependent values accordingly.
  1842. ;
  1843. init1:        cmp al,7                      ;is current video mode 7?
  1844.               je init2                      ;yes, then branch
  1845.               cmp al,15                     ;is current video mode 15?
  1846.               jne init3                     ;no, then skip modification code
  1847. init2:        sub video_segment,800h        ;set VIDEO_SEGMENT for monochrome
  1848.               mov border_attr,07h           ;change attributes for monochrome
  1849.               mov text_attr,07h
  1850.               mov header_attr,07h
  1851.               mov reverse_attr,70h
  1852.               mov title_attr,70h
  1853. ;
  1854. ;Reset the cursor to scan lines 6 and 7 (color) or 12 and 13 (monochrome).
  1855. ;
  1856. init3:        mov cx,0C0Dh                  ;monochrome cursor type
  1857.               cmp al,7                      ;video mode 7?
  1858.               je init4                      ;yes, then jump
  1859.               cmp al,15                     ;video mode 15?
  1860.               je init4                      ;yes, then jump
  1861.               mov cx,0607h                  ;scan lines 6 and 7 for color
  1862. init4:        mov ah,1                      ;set cursor type
  1863.               int 10h
  1864. ;
  1865. ;before we go, let them know who we are
  1866. ;
  1867.               lea dx, credit$
  1868.               call list$
  1869. ;
  1870. ;Now save the old interrupt 9 vector and replace it with one pointing to the
  1871. ;code that we will leave behind in memory.
  1872. ;
  1873.               mov ah,35h                    ;get current interrupt 9 vector
  1874.               mov al,9
  1875.               int 21h
  1876.               mov old_keyboard_int,bx       ;save vector offset
  1877.               mov old_keyboard_int[2],es    ;save vector segment
  1878.               mov ah,25h                    ;set new vector
  1879.               mov al,9
  1880.               lea dx,mikview                ;point it to body of program
  1881.               int 21h
  1882. ;
  1883. ;Exit thru INT 27h and reserve enough room beyond the actual code to store the
  1884. ;contents of the area of screen that underlies the pop-up window.
  1885. ;
  1886.               mov dx,offset initialize+4000 ;reserve space for code and buffer
  1887.               int 27h                       ;terminate-but-stay-resident
  1888.  
  1889. initialize    endp
  1890. ;
  1891. code          ends
  1892.               end begin
  1893.